home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Skunkware 5
/
Skunkware 5.iso
/
src
/
X11
/
xsw
/
ps.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-07-07
|
31KB
|
1,022 lines
/*
* @(#) ps.c 12.1 95/07/07 SCOINC
*/
/***************************************************************************
*
* Copyright (c) 1990-1993 The Santa Cruz Operation, Inc.
*
* All rights reserved. No part of this program or publication may be
* reproduced, transmitted, transcribed, stored in a retrieval system,
* or translated into any language or computer language, in any form or
* by any means, electronic, mechanical, magnetic, optical, chemical,
* biological, or otherwise, without the prior written permission of:
*
* The Santa Cruz Operation , Inc. (408) 425-7222
* 400 Encinal St., Santa Cruz, California 95060 USA
*
**************************************************************************/
/*
* Modification History
*
* S003, 15-Sep-93, rickra
* Oh OH, added disk space code .....
*
* S002, 27-May-93, rickra
* Put all "PS" specific stuff here... That is, code that PS MEM,
* PS I/O, and PS CPU share, in this file......
*
* S001, 01-Jan-93, rickra
* Added support for seperate windows.
* Took out PSIO PSMEM PSCPU specific code and made new files with it.
*
* S000, 30-Sep-92, rickra
* Added copyright and modification history
* Change hard coded color referneces to user configurable.
*/
/*+-------------------------------------------------------------------------
ps.c - XSW proc status detail
Defined functions:
find_utmp_for_pgrp(pgrp)
get_cpu_time_str(ticks)
get_user(tproc,tuser)
getpwent_and_enter(uid)
init_uid_name_hash()
initialize_Ps()
pgrp_to_ttyname(pgrp)
ppproc_pid_compare(ppp1,ppp2)
sort_procs(initial)
read_utmp()
uid_name_enter(uid,name)
--------------------------------------------------------------------------*/
/*+:EDITS:*/
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
#include <X11/StringDefs.h>
#include <Xm/Xm.h>
#include <Xm/MainW.h>
#include <Xm/DrawingA.h>
#include "include/unixincs.h"
#include "include/resources.h"
#include "include/xswboth.h"
#include "include/buttons.h"
#include "include/libkmem.h"
#include "include/libmem.h"
#include "include/libswap.h"
#include "include/xsw.h"
#include "include/sepwin.h"
extern struct NetworkXswStruct *current_server;
extern MyResources res;
static int max_procs_to_display = 0;
/*
* The following are used in both pscpu.c and psio.c, thus the variables
* are defined here....
*/
/*
* These two are place holders and can be global?????
*/
struct my_user_struct user;
struct my_user_struct old_user;
static int line_style = LineSolid;
static int cap_style = CapButt;
static int join_style = JoinMiter;
/*
* PS MEM external defined functions
*/
extern process_mem_user_compare (process_memory * ppp1, process_memory * ppp2);
extern process_mem_pid_compare (process_memory * ppp1, process_memory * ppp2);
extern process_mem_vsize_compare (process_memory * ppp1, process_memory * ppp2);
extern process_mem_shrd_compare (process_memory * ppp1, process_memory * ppp2);
extern process_mem_priv_compare (process_memory * ppp1, process_memory * ppp2);
extern process_mem_wtd_compare (process_memory * ppp1, process_memory * ppp2);
extern process_memory_compare (process_memory * ppp1, process_memory * ppp2);
extern process_mem_cmd_compare (process_memory * ppp1, process_memory * ppp2);
extern process_mem_none_compare (process_memory * ppp1, process_memory * ppp2);
extern process_mem_swap_compare (process_memory * ppp1, process_memory * ppp2);
extern process_mem_file_compare (process_memory * ppp1, process_memory * ppp2);
extern process_mem_lstfile_compare (process_memory * ppp1, process_memory * ppp2);
extern process_mem_zero_compare (process_memory * ppp1, process_memory * ppp2);
extern process_mem_fill_compare (process_memory * ppp1, process_memory * ppp2);
extern process_mem_iomap_compare (process_memory * ppp1, process_memory * ppp2);
#ifndef XSW32v5
extern process_mem_window_compare (process_memory * ppp1, process_memory * ppp2);
#endif
extern process_mem_swap_core_compare (process_memory * ppp1, process_memory * ppp2);
extern process_mem_file_core_compare (process_memory * ppp1, process_memory * ppp2);
extern process_mem_lstfile_core_compare (process_memory * ppp1, process_memory * ppp2);
extern process_mem_swap_not_core_compare (process_memory * ppp1, process_memory * ppp2);
extern process_mem_file_not_core_compare (process_memory * ppp1, process_memory * ppp2);
extern process_mem_lstfile_not_core_compare (process_memory * ppp1, process_memory * ppp2);
extern process_mem_core_dbd_compare (process_memory * ppp1, process_memory * ppp2);
/*
* PS IO external defined functions
*/
extern ppproc_io_user_compare (struct my_proc_struct **ppp1,
struct my_proc_struct **ppp2);
extern ppproc_io_pid_compare (struct my_proc_struct **ppp1,
struct my_proc_struct **ppp2);
extern ppproc_io_swap_compare (struct my_proc_struct **ppp1,
struct my_proc_struct **ppp2);
extern ppproc_io_char_compare (struct my_proc_struct **ppp1,
struct my_proc_struct **ppp2);
extern ppproc_io_read_compare (struct my_proc_struct **ppp1,
struct my_proc_struct **ppp2);
extern ppproc_io_write_compare (struct my_proc_struct **ppp1,
struct my_proc_struct **ppp2);
extern ppproc_io_total_compare (struct my_proc_struct **ppp1,
struct my_proc_struct **ppp2);
extern ppproc_io_cmd_compare (struct my_proc_struct **ppp1,
struct my_proc_struct **ppp2);
/*
* PS CPU external defined functions
*/
extern ppproc_state_compare (struct my_proc_struct **ppp1,
struct my_proc_struct **ppp2);
extern ppproc_user_compare (struct my_proc_struct **ppp1,
struct my_proc_struct **ppp2);
extern ppproc_pid_compare (struct my_proc_struct **ppp1,
struct my_proc_struct **ppp2);
extern ppproc_cpu_compare (struct my_proc_struct **ppp1,
struct my_proc_struct **ppp2);
extern ppproc_pri_compare (struct my_proc_struct **ppp1,
struct my_proc_struct **ppp2);
extern ppproc_ni_compare (struct my_proc_struct **ppp1,
struct my_proc_struct **ppp2);
extern ppproc_ucpu_compare (struct my_proc_struct **ppp1,
struct my_proc_struct **ppp2);
extern ppproc_ucpu_scpu_compare (struct my_proc_struct **ppp1,
struct my_proc_struct **ppp2);
extern ppproc_scpu_compare (struct my_proc_struct **ppp1,
struct my_proc_struct **ppp2);
extern ppproc_size_compare (struct my_proc_struct **ppp1,
struct my_proc_struct **ppp2);
extern ppproc_tty_compare (struct my_proc_struct **ppp1,
struct my_proc_struct **ppp2);
extern ppproc_cmd_compare (struct my_proc_struct **ppp1,
struct my_proc_struct **ppp2);
void
change_the_buttons (SP,
number_of_buttons,
seperate_window,
menulist,
temp_toggle_widget)
struct NetworkXswStruct *SP;
int number_of_buttons;
int seperate_window;
ps_menu_struct *menulist;
Widget *temp_toggle_widget;
{
Arg args[32];
int argcount;
int j = 0;
int value;
int slider_size;
int increment_return;
int page_increment_return;
int i = 0;
XFontStruct *Current_Font;
XmFontList Font_List;
/*
fprintf (stdout, "In change_the_buttons\n");
*/
XmScrollBarGetValues (SP -> SEPERATE_WINDOWS_LIST[seperate_window].hsb,
&value,
&slider_size,
&increment_return,
&page_increment_return);
Current_Font = XLoadQueryFont (display, SP -> font_name);
Font_List = XmFontListCreate (Current_Font, XmSTRING_DEFAULT_CHARSET);
/*
* Adjust the menu button.....
*/
if (SP -> SEPERATE_WINDOWS_LIST[seperate_window].menu_bar != 0)
{
argcount = 0;
XtSetArg (args[argcount], XmNfontList, Font_List);
argcount++;
XtSetValues (SP ->
SEPERATE_WINDOWS_LIST[seperate_window].view_toggle_widget,
args, argcount);
argcount = 0;
XtSetArg (args[argcount], XmNrightAttachment, XmATTACH_FORM);
argcount++;
XtSetArg (args[argcount], XmNrightOffset,
9 * FWIDTH);
argcount++;
XtSetArg (args[argcount], XmNmarginHeight, 0);
argcount++;
XtSetArg (args[argcount], XmNmarginWidth, 0);
argcount++;
XtSetArg (args[argcount], XmNshadowThickness, 1);
argcount++;
XtSetValues (SP ->
SEPERATE_WINDOWS_LIST[seperate_window].menu_bar,
args, argcount);
/*
* Also need to adjust the menu list itself.... not just the button....
*/
for (i = 0; i < 4; i++)
{
argcount = 0;
XtSetArg (args[argcount], XmNfontList, Font_List);
argcount++;
XtSetValues (SP ->
SEPERATE_WINDOWS_LIST[seperate_window].screen_widget_list[i],
args, argcount);
}
}
for (j = 0; j < number_of_buttons; j++)
{
if (menulist[j].type == SORT_BUTTON)
{
argcount = 0;
XtSetArg (args[argcount], XmNfontList, Font_List);
argcount++;
XtSetArg (args[argcount], XmNmarginBottom, 0);
argcount++;
XtSetArg (args[argcount], XmNmarginTop, 0);
argcount++;
XtSetArg (args[argcount], XmNleftAttachment, XmATTACH_FORM);
argcount++;
XtSetArg (args[argcount], XmNleftOffset,
((4 + (menulist[j].offset * FWIDTH) - value)));
argcount++;
XtSetValues (temp_toggle_widget[j], args, argcount);
}
else
{
argcount = 0;
XtSetArg (args[argcount], XmNfontList, Font_List);
argcount++;
XtSetArg (args[argcount], XmNmarginBottom, 0);
argcount++;
XtSetArg (args[argcount], XmNmarginTop, 0);
argcount++;
XtSetArg (args[argcount], XmNrightAttachment, XmATTACH_FORM);
argcount++;
XtSetArg (args[argcount], XmNrightOffset,
((4 + (menulist[j].offset * FWIDTH))));
argcount++;
XtSetValues (temp_toggle_widget[j], args, argcount);
}
}
}
adjust_ps_button_offsets (SP)
struct NetworkXswStruct *SP;
{
int i, j;
Arg args[32];
int argcount;
int number_of_buttons = 0;
int seperate_window = 0;
Dimension t1, t2, t3, t4, t5, t6;
ps_menu_struct *menulist;
Widget *temp_toggle_widget;
XFontStruct *Current_Font;
XmFontList Font_List;
/*
fprintf (stdout, "In adjust ps buttons\n");
*/
Current_Font = XLoadQueryFont (display, SP -> font_name);
Font_List = XmFontListCreate (Current_Font, XmSTRING_DEFAULT_CHARSET);
for (i = 0; i < SP -> current_items; i++)
{
if ((SP -> DISPLAY_LIST[i].button_num == BUTTON_ps_cpu) ||
(SP -> DISPLAY_LIST[i].button_num == BUTTON_ps_io) ||
(SP -> DISPLAY_LIST[i].button_num == BUTTON_ps_mem) ||
(SP -> DISPLAY_LIST[i].button_num == BUTTON_disk_space))
{
argcount = 0;
XtSetArg (args[argcount], XmNfontList, Font_List);
argcount++;
XtSetArg (args[argcount], XmNmarginBottom, 0);
argcount++;
XtSetArg (args[argcount], XmNmarginTop, 0);
argcount++;
XtSetValues (SP -> SEPERATE_WINDOWS_LIST[
SP -> DISPLAY_LIST[i].button_num].title_label,
args,
argcount);
argcount = 0;
XtSetArg (args[argcount], XmNpaneMinimum, (FHEIGHT * 3));
argcount++;
XtSetArg (args[argcount], XmNpaneMaximum, (FHEIGHT * 3));
argcount++;
XtSetValues (SP -> SEPERATE_WINDOWS_LIST[
SP -> DISPLAY_LIST[i].button_num].form_w,
args,
argcount);
if (SP -> DISPLAY_LIST[i].button_num == BUTTON_ps_cpu)
{
number_of_buttons = XtNumber (ps_toggle_button_data);
seperate_window = BUTTON_ps_cpu;
menulist = ps_toggle_button_data;
temp_toggle_widget =
SP -> SEPERATE_WINDOWS_LIST[seperate_window].toggle_widget;
change_the_buttons (SP,
number_of_buttons,
seperate_window,
menulist,
temp_toggle_widget);
}
else if (SP -> DISPLAY_LIST[i].button_num == BUTTON_ps_io)
{
number_of_buttons = XtNumber (ps_io_toggle_button_data);
seperate_window = BUTTON_ps_io;
menulist = ps_io_toggle_button_data;
temp_toggle_widget =
SP -> SEPERATE_WINDOWS_LIST[seperate_window].toggle_widget;
change_the_buttons (SP,
number_of_buttons,
seperate_window,
menulist,
temp_toggle_widget);
}
else if (SP -> DISPLAY_LIST[i].button_num == BUTTON_ps_mem)
{
number_of_buttons = XtNumber (ps_mem_toggle_button_data);
seperate_window = BUTTON_ps_mem;
menulist = ps_mem_toggle_button_data;
temp_toggle_widget =
SP -> SEPERATE_WINDOWS_LIST[seperate_window].toggle_widget;
change_the_buttons (SP,
number_of_buttons,
seperate_window,
menulist,
temp_toggle_widget);
}
else if (SP -> DISPLAY_LIST[i].button_num == BUTTON_disk_space)
{
number_of_buttons = XtNumber (disk_space_toggle_button_data);
seperate_window = BUTTON_disk_space;
menulist = disk_space_toggle_button_data;
temp_toggle_widget =
SP -> SEPERATE_WINDOWS_LIST[seperate_window].toggle_widget;
change_the_buttons (SP,
number_of_buttons,
seperate_window,
menulist,
temp_toggle_widget);
}
}
}
}
void
sort_processes (button_num)
int button_num;
{
/*
fprintf(stdout,"about to sort process\n");
*/
switch (button_num)
{
case BUTTON_ps_cpu:
switch (current_server -> ps_sort_mode)
{
case BUTTON_PS_state_sort - 25:
(void) qsort ((char *) current_server -> pprocs, (unsigned) current_server -> slots_in_use,
sizeof (struct my_proc_struct *), ppproc_state_compare);
break;
case BUTTON_PS_user_sort - 25:
(void) qsort ((char *) current_server -> pprocs, (unsigned) current_server -> slots_in_use,
sizeof (struct my_proc_struct *), ppproc_user_compare);
break;
case BUTTON_PS_pid_sort - 25:
(void) qsort ((char *) current_server -> pprocs, (unsigned) current_server -> slots_in_use,
sizeof (struct my_proc_struct *), ppproc_pid_compare);
break;
case BUTTON_PS_cpu_sort - 25:
(void) qsort ((char *) current_server -> pprocs, (unsigned) current_server -> slots_in_use,
sizeof (struct my_proc_struct *), ppproc_cpu_compare);
break;
case BUTTON_PS_pri_sort - 25:
(void) qsort ((char *) current_server -> pprocs, (unsigned) current_server -> slots_in_use,
sizeof (struct my_proc_struct *), ppproc_pri_compare);
break;
case BUTTON_PS_ni_sort - 25:
(void) qsort ((char *) current_server -> pprocs, (unsigned) current_server -> slots_in_use,
sizeof (struct my_proc_struct *), ppproc_ni_compare);
break;
case BUTTON_PS_ucpu_sort - 25:
(void) qsort ((char *) current_server -> pprocs, (unsigned) current_server -> slots_in_use,
sizeof (struct my_proc_struct *), ppproc_ucpu_compare);
break;
case BUTTON_PS_ucpu_scpu_sort - 25:
(void) qsort ((char *) current_server -> pprocs, (unsigned) current_server -> slots_in_use,
sizeof (struct my_proc_struct *), ppproc_ucpu_scpu_compare);
break;
case BUTTON_PS_scpu_sort - 25:
(void) qsort ((char *) current_server -> pprocs, (unsigned) current_server -> slots_in_use,
sizeof (struct my_proc_struct *), ppproc_scpu_compare);
break;
case BUTTON_PS_size_sort - 25:
(void) qsort ((char *) current_server -> pprocs, (unsigned) current_server -> slots_in_use,
sizeof (struct my_proc_struct *), ppproc_size_compare);
break;
case BUTTON_PS_tty_sort - 25:
(void) qsort ((char *) current_server -> pprocs, (unsigned) current_server -> slots_in_use,
sizeof (struct my_proc_struct *), ppproc_tty_compare);
break;
case BUTTON_PS_cmd_sort - 25:
(void) qsort ((char *) current_server -> pprocs, (unsigned) current_server -> slots_in_use,
sizeof (struct my_proc_struct *), ppproc_cmd_compare);
break;
}
break;
case BUTTON_ps_io:
switch (current_server -> ps_io_sort_mode)
{
case BUTTON_IO_PS_user_sort - 40:
(void) qsort ((char *) current_server -> pprocs, (unsigned) current_server -> slots_in_use,
sizeof (struct my_proc_struct *), ppproc_io_user_compare);
break;
case BUTTON_IO_PS_pid_sort - 40:
(void) qsort ((char *) current_server -> pprocs, (unsigned) current_server -> slots_in_use,
sizeof (struct my_proc_struct *), ppproc_io_pid_compare);
break;
case BUTTON_IO_PS_swap_sort - 40:
(void) qsort ((char *) current_server -> pprocs, (unsigned) current_server -> slots_in_use,
sizeof (struct my_proc_struct *), ppproc_io_swap_compare);
break;
case BUTTON_IO_PS_char_sort - 40:
(void) qsort ((char *) current_server -> pprocs, (unsigned) current_server -> slots_in_use,
sizeof (struct my_proc_struct *), ppproc_io_char_compare);
break;
case BUTTON_IO_PS_read_sort - 40:
(void) qsort ((char *) current_server -> pprocs, (unsigned) current_server -> slots_in_use,
sizeof (struct my_proc_struct *), ppproc_io_read_compare);
break;
case BUTTON_IO_PS_write_sort - 40:
(void) qsort ((char *) current_server -> pprocs, (unsigned) current_server -> slots_in_use,
sizeof (struct my_proc_struct *), ppproc_io_write_compare);
break;
case BUTTON_IO_PS_total_sort - 40:
(void) qsort ((char *) current_server -> pprocs, (unsigned) current_server -> slots_in_use,
sizeof (struct my_proc_struct *), ppproc_io_total_compare);
break;
case BUTTON_IO_PS_cmd_sort - 40:
(void) qsort ((char *) current_server -> pprocs, (unsigned) current_server -> slots_in_use,
sizeof (struct my_proc_struct *), ppproc_io_cmd_compare);
break;
}
break;
case BUTTON_ps_mem:
switch (current_server -> ps_mem_screen_mode)
{
case 1:
switch (current_server -> ps_mem_sort_mode[0])
{
case BUTTON_MEM_PS_user_sort - 60:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_user_compare);
break;
case BUTTON_MEM_PS_pid_sort - 60:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_pid_compare);
break;
case BUTTON_MEM_PS_vsize_sort - 60:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_vsize_compare);
break;
case BUTTON_MEM_PS_shrd_sort - 60:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_shrd_compare);
break;
case BUTTON_MEM_PS_priv_sort - 60:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_priv_compare);
break;
case BUTTON_MEM_PS_wtd_sort - 60:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_wtd_compare);
break;
case BUTTON_MEM_PS_total_sort - 60:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_memory_compare);
break;
case BUTTON_MEM_PS_cmd_sort - 60:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_cmd_compare);
break;
}
break;
case 2:
switch (current_server -> ps_mem_sort_mode[1])
{
case 0:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_user_compare);
break;
case 1:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_pid_compare);
break;
case 2:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_vsize_compare);
break;
case 3:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_none_compare);
break;
case 4:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_swap_core_compare);
break;
case 5:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_file_core_compare);
break;
case 6:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_lstfile_core_compare);
break;
case 7:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_core_dbd_compare);
break;
case 8:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_cmd_compare);
break;
}
break;
case 3:
switch (current_server -> ps_mem_sort_mode[2])
{
case 0:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_user_compare);
break;
case 1:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_pid_compare);
break;
case 2:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_vsize_compare);
break;
case 3:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_none_compare);
break;
case 4:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_swap_compare);
break;
case 5:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_file_compare);
break;
case 6:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_lstfile_compare);
break;
case 7:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_zero_compare);
break;
case 8:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_fill_compare);
break;
case 9:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_iomap_compare);
break;
#ifndef XSW32v5
case 10:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_window_compare);
break;
#endif
case 11:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_cmd_compare);
break;
}
break;
case 4:
switch (current_server -> ps_mem_sort_mode[3])
{
case 0:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_user_compare);
break;
case 1:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_pid_compare);
break;
case 2:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_vsize_compare);
break;
case 3:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_swap_not_core_compare);
break;
case 4:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_file_not_core_compare);
break;
case 5:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_lstfile_not_core_compare);
break;
case 6:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_zero_compare);
break;
case 7:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_fill_compare);
break;
case 8:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_iomap_compare);
break;
#ifndef XSW32v5
case 9:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_window_compare);
break;
#endif
case 10:
(void) qsort ((char *) current_server -> heap_memory_pointer,
(unsigned) current_server -> current_mem_procs,
sizeof (process_memory),
process_mem_cmd_compare);
break;
}
break;
}
break;
}
/*
fprintf(stdout,"about to leave sort process\n");
*/
}
/*+-------------------------------------------------------------------------
sort_procs(button_num)
--------------------------------------------------------------------------*/
void
sort_procs (button_num)
int button_num;
{
int iproc;
register char *cptr;
register struct my_proc_struct *tproc;
/* if slot not in use, force to end when sorting */
current_server -> nprocs = 0;
for (iproc = 0; iproc < current_server -> slots_in_use; iproc++)
{
tproc = current_server -> pprocs[iproc];
if (tproc -> p_stat == 0) /* if slot not in use, ... */
{ /* eliminate from consideration */
tproc -> p_pid = 32767; /* force below selected procs in
* qsort */
continue;
}
current_server -> nprocs++;
}
/* sort new procs array */
sort_processes (button_num);
} /* end of sort_procs */
/*+-------------------------------------------------------------------------
get_old_user(tproc,tuser) - read user struct for pid
return 1 if successful, else 0 if not available
--------------------------------------------------------------------------*/
int
get_old_user (tproc, tuser)
struct my_proc_struct *tproc;
struct my_user_struct *tuser;
{
int i;
struct my_user_struct *start_my_user;
if (current_server -> old_my_user != NULL)
{
start_my_user = current_server -> old_my_user;
for (i = 0; i < current_server -> old_slots_in_use; i++)
{
if (start_my_user -> p_pid == tproc -> p_pid)
{
tuser -> u_tsize = start_my_user -> u_tsize;
tuser -> u_dsize = start_my_user -> u_dsize;
tuser -> u_ssize = start_my_user -> u_ssize;
tuser -> u_utime = start_my_user -> u_utime;
tuser -> u_stime = start_my_user -> u_stime;
tuser -> u_ior = start_my_user -> u_ior;
tuser -> u_iow = start_my_user -> u_iow;
tuser -> u_iosw = start_my_user -> u_iosw;
tuser -> u_ioch = start_my_user -> u_ioch;
strcpy (tuser -> u_psargs, start_my_user -> u_psargs);
strcpy (tuser -> u_comm, start_my_user -> u_comm);
return (1);
}
start_my_user++;
}
}
return (0);
} /* end of get_old_user */
/*+-------------------------------------------------------------------------
get_user(tproc,tuser) - read user struct for pid
return 1 if successful, else 0 if not available
--------------------------------------------------------------------------*/
int
get_user (tproc, tuser)
struct my_proc_struct *tproc;
struct my_user_struct *tuser;
{
int i;
struct my_user_struct *start_my_user;
start_my_user = current_server -> my_user;
for (i = 0; i < current_server -> slots_in_use; i++)
{
if (start_my_user -> p_pid == tproc -> p_pid)
{
tuser -> u_tsize = start_my_user -> u_tsize;
tuser -> u_dsize = start_my_user -> u_dsize;
tuser -> u_ssize = start_my_user -> u_ssize;
tuser -> u_utime = start_my_user -> u_utime;
tuser -> u_stime = start_my_user -> u_stime;
tuser -> u_ior = start_my_user -> u_ior;
tuser -> u_iow = start_my_user -> u_iow;
tuser -> u_iosw = start_my_user -> u_iosw;
tuser -> u_ioch = start_my_user -> u_ioch;
strcpy (tuser -> u_psargs, start_my_user -> u_psargs);
strcpy (tuser -> u_comm, start_my_user -> u_comm);
return (1);
}
start_my_user++;
}
return (0);
} /* end of get_user */
/*+-------------------------------------------------------------------------
initialize_Ps()
--------------------------------------------------------------------------*/
void
initialize_Ps ()
{
#ifdef DEBUG1
fprintf (stdout, "About to start initialize_Ps\n");
#endif
} /* end of initialize_Ps */
/* vi: set tabstop=4 shiftwidth=4: */
/* end of ps.c */